Skip to content

changed: NonLinMPC defaults to transcription=MultipleShooting() - #539

Merged
franckgaga merged 15 commits into
mainfrom
nmpc_ms_default
Dec 2, 2026
Merged

franckgaga merged 15 commits into
mainfrom
nmpc_ms_default

Conversation

@franckgaga

@franckgaga franckgaga commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Warning

This is a breaking change, the default transcription method for NonLinMPC based on LinModel or NonLinModel is now MultipleShooting(), instead of SingleShooting(). The default for NonLinModelDAE is still the collocation method defined in model.transcription, like before.

Four justifications for this breaking change:

  1. This is the "consensus" in the literature: multiple shooting is generally faster and more robust for highly nonlinear models.
  2. From my experiences on the pendulum, the MultipleShooting() is always faster than SingleShooting() (now that the logic is always based on MOI.VectorNonlinearOracle).
  3. It helps convergence from my experiences on the pendulum, especially for funnelsqp and filtersqp presets of UnoSolver.jl.
  4. This is the default transcription method used by MATLAB nlmpc object when the plant model is discrete-time, so this is a smooth transition for people coming from there.

This breaking change can be easily reverted by explicitly specifying transcription=SingleShooting() in NonLinMPC constructor.

Except for `NonLinModelDAE`, in which it defaults to the collocation method defined in `model.transcription`, as it was the case before.
To improve coverage of `SingleShooting` transcription.
@codecov-commenter

codecov-commenter commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.08%. Comparing base (02d4573) to head (c079eb0).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #539      +/-   ##
==========================================
+ Coverage   99.06%   99.08%   +0.02%     
==========================================
  Files          30       30              
  Lines        8446     8452       +6     
==========================================
+ Hits         8367     8375       +8     
+ Misses         79       77       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@franckgaga
franckgaga merged commit 33d7200 into main Dec 2, 2026
11 of 12 checks passed
@franckgaga
franckgaga deleted the nmpc_ms_default branch December 2, 2026 17:06
@franckgaga

franckgaga commented Dec 2, 2026 •

Copy link
Copy Markdown
Member Author

Here are the main benchmark results that motivate this change from the suite (ran with github action on this branch):

c079eb0...
Pendulum/NonLinMPC/Custom constraints/Ipopt/SingleShooting 1.01 ± 0.0052 s
Pendulum/NonLinMPC/Custom constraints/Ipopt/MultipleShooting 0.366 ± 0.0073 s
Pendulum/NonLinMPC/Economic/Ipopt/SingleShooting 0.378 ± 0.0008 s
Pendulum/NonLinMPC/Economic/Ipopt/MultipleShooting 0.219 ± 0.0019 s
Pendulum/NonLinMPC/Noneconomic/Ipopt/SingleShooting 0.309 ± 0.0017 s
Pendulum/NonLinMPC/Noneconomic/Ipopt/MultipleShooting 0.238 ± 0.0018 s
Pendulum/NonLinMPC/Noneconomic/Ipopt/SingleShooting (Hessian) 0.11 ± 0.0014 s
Pendulum/NonLinMPC/Noneconomic/Ipopt/MultipleShooting (Hessian) 0.279 ± 0.0021 s
Pendulum/NonLinMPC/Noneconomic/MadNLP/SingleShooting (Hessian) 0.0446 ± 0.00032 s
Pendulum/NonLinMPC/Noneconomic/MadNLP/MultipleShooting (Hessian) 0.197 ± 0.0013 s

Multiple shooting is generally faster than single shooting, especially for highly nonlinear constraints i.e. the "Custom constraints" case study. The the hessian=true cases are slightly slower (presumably because slower AD), but I'm okay with this since:

  1. Apart from raw speed, the convergence is typically improved with multiple shooting, as explained above in the first post.
  2. the default is hessian=false for NonLinMPC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants